package cn.ddiancan.schedule.business.service.impl;

import cn.ddiancan.schedule.base.domain.TaskDTO;
import cn.ddiancan.schedule.business.service.AbastractScheduleExecutor;
import cn.ddiancan.schedule.business.job.ISchedulerJob;
import cn.ddiancan.xddcloud.common.context.SpringContextUtils;
import cn.ddiancan.xddcloud.common.entity.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service("beanTaskExecutor")
public class BeanExecutor extends AbastractScheduleExecutor {

    @Override
    public void execute(TaskDTO taskDTO, Runnable runnable) {
        String executeBean = taskDTO.getExecuteBean();
        ISchedulerJob schedulerJob = SpringContextUtils.getBean(executeBean,ISchedulerJob.class);
        CommonResult<?> execute = schedulerJob.executeJob();
        if (execute.getCode() == 200) {
            log.info("执行成功:{}", execute.getData());
        }
    }
}
